//
//  MemberNavigationController.swift
//  GhostWorld
//
//  Created by Kam on 2018/5/16.
//  Copyright © 2018 LKGood. All rights reserved.
//

import UIKit

class VIPNavigationController: BaseNavigationController {
  
  // MARK: - IBOutlets
  
  
  
  // MARK: - Private vars
  
  
  
  // MARK: - Private methods
  
  @objc private func resetRootView() {
    if let currentUser = UserManager.shared.currentUser,
      currentUser.isPremium {
      let storyboard = UIStoryboard(name: "VIP", bundle: nil)
      let vipHomeViewController = storyboard.instantiateViewController(withIdentifier: "VIPHomeViewController")
      setViewControllers([vipHomeViewController], animated: true)
      
    } else {
      let storyboard = UIStoryboard(name: "VIP", bundle: nil)
      let vipTipViewController = storyboard.instantiateViewController(withIdentifier: "VIPTipViewController")
      setViewControllers([vipTipViewController], animated: true)
    }
  }
  
  // MARK: - Public vars
  
  
  
  // MARK: - Lifecycle
  
  
  
  // MARK: - IBActions
  
  
  
  // MARK: - Public methods
  
  
  override func viewDidLoad() {
    super.viewDidLoad()
    
    NotificationCenter.default.addObserver(self, selector: #selector(resetRootView), name: .currentUserUpdated, object: nil)
    
    resetRootView()
  }
  
  override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
  }
  
  deinit {
    NotificationCenter.default.removeObserver(self)
  }
}
